package com.trafficsys.modules.owner.controller;

import com.trafficsys.modules.entity.Ticket;
import com.trafficsys.modules.owner.service.TicketRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/api")
public class TicketsController {
    @Autowired
    private TicketRecordService ticketRecordService;

    /**
     * 根据carNo获取违章记录
     * http://localhost:8080/api/getTicketRecord/222
     *
     * @param carNo
     * @return
     */
    @GetMapping("/getTicketRecord/{carNo}")
    public Map<String, Object> getTicketRecord(@PathVariable String carNo) {
        List<Ticket> list = ticketRecordService.queryTicket(carNo);
        //通过条件分页查询
        //带条件不分页获取总条数

        Map<String, Object> result = new HashMap<>();
        result.put("info", list);
        result.put("total", 20);
        result.put("totalPage", 5);
        return result;
    }

}
